package megadrum.gui;

import java.lang.reflect.Method;
import megadrum.*;
import megadrum.mididata.Converter;
import javax.swing.JSpinner;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class HihatPanel extends javax.swing.JPanel implements ChangeListener {

    public HihatPanel(MegadrumConfigTool mct) {
        parent = mct;
        initComponents();
        initComponents2();
    }

    //init components (1)
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
        type = new javax.swing.JSpinner();
        curve = new javax.swing.JSpinner();
        chickDelay = new javax.swing.JSpinner();
        altIn = new javax.swing.JSpinner();
        ccValue = new javax.swing.JSpinner();
        autoLevels = new javax.swing.JSpinner();
        lowLevel = new javax.swing.JSpinner();
        highLevel = new javax.swing.JSpinner();
        openLevel = new javax.swing.JSpinner();
        closedLevel = new javax.swing.JSpinner();
        bowCL = new javax.swing.JSpinner();
        edgeCL = new javax.swing.JSpinner();
        javax.swing.JLabel jLabel2 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel4 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel5 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel6 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel7 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel8 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel9 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel10 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel11 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel12 = new javax.swing.JLabel();
        chickNote = new javax.swing.JSpinner();
        splashNote = new javax.swing.JSpinner();
        javax.swing.JLabel jLabel13 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel14 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel15 = new javax.swing.JLabel();
        thresShort = new javax.swing.JSpinner();
        javax.swing.JLabel jLabel16 = new javax.swing.JLabel();
        bellCL = new javax.swing.JSpinner();
        bellHO = new javax.swing.JSpinner();
        javax.swing.JLabel jLabel17 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel18 = new javax.swing.JLabel();
        edgeHO = new javax.swing.JSpinner();
        javax.swing.JLabel jLabel19 = new javax.swing.JLabel();
        bowHO = new javax.swing.JSpinner();
        cymbalInput = new javax.swing.JSpinner();
        javax.swing.JLabel jLabel20 = new javax.swing.JLabel();
        javax.swing.JLabel jLabel21 = new javax.swing.JLabel();
        thresLong = new javax.swing.JSpinner();
        javax.swing.JLabel jLabel22 = new javax.swing.JLabel();
        reverseLevels = new javax.swing.JSpinner();

        setBorder(javax.swing.BorderFactory.createTitledBorder("Hihat Pedal"));

        jLabel1.setText("Type");

        type.setMaximumSize(new java.awt.Dimension(80, 20));
        type.setMinimumSize(new java.awt.Dimension(80, 20));
        type.setPreferredSize(new java.awt.Dimension(29, 20));

        curve.setMaximumSize(new java.awt.Dimension(80, 20));
        curve.setMinimumSize(new java.awt.Dimension(80, 20));
        curve.setPreferredSize(new java.awt.Dimension(29, 20));

        chickDelay.setMaximumSize(new java.awt.Dimension(80, 20));
        chickDelay.setMinimumSize(new java.awt.Dimension(80, 20));
        chickDelay.setPreferredSize(new java.awt.Dimension(29, 20));

        altIn.setMaximumSize(new java.awt.Dimension(80, 20));
        altIn.setMinimumSize(new java.awt.Dimension(80, 20));
        altIn.setPreferredSize(new java.awt.Dimension(29, 20));

        ccValue.setMaximumSize(new java.awt.Dimension(80, 20));
        ccValue.setMinimumSize(new java.awt.Dimension(80, 20));
        ccValue.setPreferredSize(new java.awt.Dimension(29, 20));

        autoLevels.setMaximumSize(new java.awt.Dimension(80, 20));
        autoLevels.setMinimumSize(new java.awt.Dimension(80, 20));
        autoLevels.setPreferredSize(new java.awt.Dimension(29, 20));

        lowLevel.setMaximumSize(new java.awt.Dimension(80, 20));
        lowLevel.setMinimumSize(new java.awt.Dimension(80, 20));
        lowLevel.setPreferredSize(new java.awt.Dimension(29, 20));

        highLevel.setMaximumSize(new java.awt.Dimension(80, 20));
        highLevel.setMinimumSize(new java.awt.Dimension(80, 20));
        highLevel.setPreferredSize(new java.awt.Dimension(29, 20));

        openLevel.setMaximumSize(new java.awt.Dimension(80, 20));
        openLevel.setMinimumSize(new java.awt.Dimension(80, 20));
        openLevel.setPreferredSize(new java.awt.Dimension(29, 20));

        closedLevel.setMaximumSize(new java.awt.Dimension(80, 20));
        closedLevel.setMinimumSize(new java.awt.Dimension(80, 20));
        closedLevel.setPreferredSize(new java.awt.Dimension(29, 20));

        bowCL.setMaximumSize(new java.awt.Dimension(80, 20));
        bowCL.setMinimumSize(new java.awt.Dimension(80, 20));
        bowCL.setPreferredSize(new java.awt.Dimension(29, 20));

        edgeCL.setMaximumSize(new java.awt.Dimension(80, 20));
        edgeCL.setMinimumSize(new java.awt.Dimension(80, 20));
        edgeCL.setPreferredSize(new java.awt.Dimension(29, 20));

        jLabel2.setText("Curve");

        jLabel3.setText("Chick Delay");

        jLabel4.setText("AltIn");

        jLabel5.setText("CC Value");

        jLabel6.setText("Auto Levels");

        jLabel7.setText("Low Level");

        jLabel8.setText("High Level");

        jLabel9.setText("Open Level");

        jLabel10.setText("Closed Level");

        jLabel11.setText("Bow Closed");

        jLabel12.setText("Edge Closed");

        chickNote.setMaximumSize(new java.awt.Dimension(80, 20));
        chickNote.setMinimumSize(new java.awt.Dimension(80, 20));
        chickNote.setPreferredSize(new java.awt.Dimension(29, 20));

        splashNote.setMaximumSize(new java.awt.Dimension(80, 20));
        splashNote.setMinimumSize(new java.awt.Dimension(80, 20));
        splashNote.setPreferredSize(new java.awt.Dimension(29, 20));

        jLabel13.setText("Chick Note");

        jLabel14.setText("Splash Note");

        jLabel15.setText("Thres. Short");

        thresShort.setMaximumSize(new java.awt.Dimension(80, 20));
        thresShort.setMinimumSize(new java.awt.Dimension(80, 20));
        thresShort.setPreferredSize(new java.awt.Dimension(29, 20));

        jLabel16.setText("Bell Closed");

        bellCL.setMaximumSize(new java.awt.Dimension(80, 20));
        bellCL.setMinimumSize(new java.awt.Dimension(80, 20));
        bellCL.setPreferredSize(new java.awt.Dimension(29, 20));

        bellHO.setMaximumSize(new java.awt.Dimension(80, 20));
        bellHO.setMinimumSize(new java.awt.Dimension(80, 20));
        bellHO.setPreferredSize(new java.awt.Dimension(29, 20));

        jLabel17.setText("Bell Half-Open");

        jLabel18.setText("Edge Half-Open");

        edgeHO.setMaximumSize(new java.awt.Dimension(80, 20));
        edgeHO.setMinimumSize(new java.awt.Dimension(80, 20));
        edgeHO.setPreferredSize(new java.awt.Dimension(29, 20));

        jLabel19.setText("Bow Half-Open");

        bowHO.setMaximumSize(new java.awt.Dimension(80, 20));
        bowHO.setMinimumSize(new java.awt.Dimension(80, 20));
        bowHO.setPreferredSize(new java.awt.Dimension(29, 20));

        cymbalInput.setMaximumSize(new java.awt.Dimension(80, 20));
        cymbalInput.setMinimumSize(new java.awt.Dimension(80, 20));
        cymbalInput.setPreferredSize(new java.awt.Dimension(29, 20));

        jLabel20.setText("Cymbal Input");

        jLabel21.setText("Thres. Long");

        thresLong.setMaximumSize(new java.awt.Dimension(80, 20));
        thresLong.setMinimumSize(new java.awt.Dimension(80, 20));
        thresLong.setPreferredSize(new java.awt.Dimension(29, 20));

        jLabel22.setText("Reverse Levels");

        reverseLevels.setMaximumSize(new java.awt.Dimension(80, 20));
        reverseLevels.setMinimumSize(new java.awt.Dimension(80, 20));
        reverseLevels.setPreferredSize(new java.awt.Dimension(29, 20));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel22)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel14)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel13)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel16)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel12)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel11)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel17)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel18)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel19)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel21)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel15)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel10)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel9)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel20)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel8)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel7)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel6)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(type, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(reverseLevels, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(chickDelay, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(altIn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(ccValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(autoLevels, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(lowLevel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(highLevel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(openLevel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(closedLevel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(thresShort, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(thresLong, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(cymbalInput, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(bowHO, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(edgeHO, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(bellHO, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(bowCL, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(edgeCL, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(bellCL, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(chickNote, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(splashNote, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(curve, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(type, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(reverseLevels, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(26, 26, 26)
                        .add(chickDelay, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(altIn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(ccValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(autoLevels, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(lowLevel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(highLevel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(openLevel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(closedLevel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(thresShort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(thresLong, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(cymbalInput, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(bowHO, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(edgeHO, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(bellHO, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(bowCL, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(edgeCL, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(bellCL, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(chickNote, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(splashNote, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(curve, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    //init components (2)

    private void initComponents2() {
        //set data models
        type.setModel(new CustomSpinnerListModel(Common.POT_FOOT));
        type.setValue(Common.POT_FOOT[1]);
        reverseLevels.setModel(new CustomSpinnerListModel(Common.NO_YES));
        curve.setModel(new CustomSpinnerListModel(Common.CURVES));
        chickDelay.setModel(new CustomSpinnerIntModel(0, 0, 127, 1));
        altIn.setModel(new CustomSpinnerListModel(Common.NO_YES));
        ccValue.setModel(new CustomSpinnerIntModel(4, 0, 127, 1));
        autoLevels.setModel(new CustomSpinnerListModel(Common.NO_YES));
        autoLevels.setValue(Common.NO_YES[1]);
        lowLevel.setModel(new CustomSpinnerIntModel(208, 11, 1022, 1));
        lowLevel.addChangeListener(this);
        highLevel.setModel(new CustomSpinnerIntModel(62, 12, 1023, 1));
        highLevel.addChangeListener(this);
        openLevel.setModel(new CustomSpinnerIntModel(8, 0, 126, 1));
        openLevel.addChangeListener(this);
        closedLevel.setModel(new CustomSpinnerIntModel(100, 1, 127, 1));
        closedLevel.addChangeListener(this);
        thresShort.setModel(new CustomSpinnerIntModel(115, 0, 127, 1));
        thresLong.setModel(new CustomSpinnerIntModel(16, 0, 127, 1));
        cymbalInput.setModel(new CustomSpinnerIntModel(2, 2, parent.getNumberOfInputs() - 1, 2));
        bowHO.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        edgeHO.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        bellHO.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        bowCL.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        edgeCL.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        bellCL.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        chickNote.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        splashNote.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));

        //parameters grouped in an array
        parameter = new JSpinner[Common.NUMBER_OF_HIHAT_PARAMETERS];
        parameter[0] = type;
        parameter[1] = reverseLevels;
        parameter[2] = altIn;
        parameter[3] = curve;
        parameter[4] = chickDelay;
        parameter[5] = ccValue;
        parameter[6] = autoLevels;
        parameter[7] = lowLevel;
        parameter[8] = highLevel;
        parameter[9] = openLevel;
        parameter[10] = closedLevel;
        parameter[11] = thresShort;
        parameter[12] = thresLong;
        parameter[13] = cymbalInput;
        parameter[14] = bowHO;
        parameter[15] = edgeHO;
        parameter[16] = bellHO;
        parameter[17] = bowCL;
        parameter[18] = edgeCL;
        parameter[19] = bellCL;
        parameter[20] = chickNote;
        parameter[21] = splashNote;

        //set a white background for all fields
        for (int j = 0; j < Common.NUMBER_OF_HIHAT_PARAMETERS; j++) {
            //change spinner colors
            ((JSpinner.DefaultEditor) parameter[j].getEditor()).getTextField().setBackground(java.awt.Color.WHITE);
            ((JSpinner.DefaultEditor) parameter[j].getEditor()).getTextField().setForeground(java.awt.Color.BLACK);
            //add change listener
            parameter[j].addChangeListener(this);
        }

        //add popup slider to fields with high value ranges
        new PopupSlider(chickDelay);
        new PopupSlider(ccValue);
        new PopupSlider(lowLevel);
        new PopupSlider(highLevel);
        new PopupSlider(openLevel);
        new PopupSlider(closedLevel);
        new PopupSlider(thresShort);
        new PopupSlider(thresLong);
        new PopupSlider(cymbalInput);
        new PopupSlider(bowHO);
        new PopupSlider(edgeHO);
        new PopupSlider(bellHO);
        new PopupSlider(bowCL);
        new PopupSlider(edgeCL);
        new PopupSlider(bellCL);
        new PopupSlider(chickNote);
        new PopupSlider(splashNote);
    }

    //set value for a field
    public void setValue(int field, int value) {
        if (field >= 0 && field < Common.NUMBER_OF_HIHAT_PARAMETERS) {
            ((CustomSpinnerModel) parameter[field].getModel()).setIntValue(value);
        }
    }

    //get value from a field
    public int getValue(int field) {
        if (field >= 0 && field < Common.NUMBER_OF_HIHAT_PARAMETERS) {
            return ((CustomSpinnerModel) parameter[field].getModel()).getIntValue();
        } else {
            return -1;
        }
    }
  /*
    public void convertSysexToData(byte sysex[]) {

        try {
            Method m = megadrum.gui.HihatPanel.class.getMethod("convertSysexToDataOld", new Class[]{byte[].class});
            m.invoke(this, sysex);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public byte[] convertDataToSysex() {
        byte[] b = new byte[0];
        try {
            Method m = megadrum.gui.HihatPanel.class.getMethod("convertDataToSysexOld", null);
            b = (byte[]) m.invoke(this, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return b;
    }
*/
    //method for converting received sysex data to values and set them in the GUI fields

    public void convertSysexToData(byte sysex[]) {
        if (sysex.length == Common.LENGTH_HIHAT) { //misc config sysex must be 31 bytes long
            tempDisableStateChangedEvents = true; //to avoid stateChanged method to be executed
            ((CustomSpinnerModel) type.getModel()).setIntValue(Converter.getIntFromBitInByte(sysex[5], 0));
            ((CustomSpinnerModel) reverseLevels.getModel()).setIntValue(Converter.getIntFromBitInByte(sysex[5], 3));
            ((CustomSpinnerModel) curve.getModel()).setIntValue(Converter.getIntFromBitsInByte(sysex[4], 4));
            ((CustomSpinnerModel) chickDelay.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[6], sysex[7]));
            ((CustomSpinnerModel) altIn.getModel()).setIntValue(Converter.getIntFromBitInByte(sysex[5], 2));
            ((CustomSpinnerModel) ccValue.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[8], sysex[9]));
            ((CustomSpinnerModel) autoLevels.getModel()).setIntValue(Converter.getIntFromBitInByte(sysex[5], 1));
            ((CustomSpinnerModel) lowLevel.getModel()).setIntValue(Converter.fourBytesToOneInt(sysex[10], sysex[11], sysex[12], sysex[13]));
            ((CustomSpinnerModel) highLevel.getModel()).setIntValue(Converter.fourBytesToOneInt(sysex[14], sysex[15], sysex[16], sysex[17]));
            ((CustomSpinnerModel) openLevel.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[18], sysex[19]));
            ((CustomSpinnerModel) closedLevel.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[20], sysex[21]));
            ((CustomSpinnerModel) thresShort.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[22], sysex[23]));
            ((CustomSpinnerModel) thresLong.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[24], sysex[25]));
            ((CustomSpinnerModel) cymbalInput.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[26], sysex[27]));
            ((CustomSpinnerModel) bowHO.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[28], sysex[29]));
            ((CustomSpinnerModel) edgeHO.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[30], sysex[31]));
            ((CustomSpinnerModel) bellHO.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[32], sysex[33]));
            ((CustomSpinnerModel) bowCL.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[34], sysex[35]));
            ((CustomSpinnerModel) edgeCL.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[36], sysex[37]));
            ((CustomSpinnerModel) bellCL.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[38], sysex[39]));
            ((CustomSpinnerModel) chickNote.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[40], sysex[41]));
            ((CustomSpinnerModel) splashNote.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[42], sysex[43]));
            tempDisableStateChangedEvents = false; //enable again stateChanged events
        }
    }
    
    //method for converting values in the GUI to a sysex message ready to be sent

    public byte[] convertDataToSysex() {
        byte[] tempByte;
        boolean[] tempBits;
        byte[] sysex = new byte[Common.LENGTH_HIHAT];
        sysex[0] = Common.SYSEX_BEGIN;
        sysex[1] = Common.SYSEX_ID;
        sysex[2] = (byte) parent.getChainID();
        sysex[3] = Common.TYPE_HIHAT;
        tempBits = Converter.intToBits(((CustomSpinnerModel) curve.getModel()).getIntValue(), 4);
        sysex[4] = Converter.bitsToNibble(tempBits[0], tempBits[1], tempBits[2], tempBits[3]);
        sysex[5] = Converter.bitsToNibble(
                ((CustomSpinnerModel) reverseLevels.getModel()).getIntValue() != 0,
                ((CustomSpinnerModel) altIn.getModel()).getIntValue() != 0,
                ((CustomSpinnerModel) autoLevels.getModel()).getIntValue() != 0,
                ((CustomSpinnerModel) type.getModel()).getIntValue() != 0);
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) chickDelay.getModel()).getIntValue());
        sysex[6] = tempByte[0];
        sysex[7] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) ccValue.getModel()).getIntValue());
        sysex[8] = tempByte[0];
        sysex[9] = tempByte[1];
        tempByte = Converter.intToFourBytes(((CustomSpinnerModel) lowLevel.getModel()).getIntValue());
        sysex[10] = tempByte[0];
        sysex[11] = tempByte[1];
        sysex[12] = tempByte[2];
        sysex[13] = tempByte[3];
        tempByte = Converter.intToFourBytes(((CustomSpinnerModel) highLevel.getModel()).getIntValue());
        sysex[14] = tempByte[0];
        sysex[15] = tempByte[1];
        sysex[16] = tempByte[2];
        sysex[17] = tempByte[3];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) openLevel.getModel()).getIntValue());
        sysex[18] = tempByte[0];
        sysex[19] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) closedLevel.getModel()).getIntValue());
        sysex[20] = tempByte[0];
        sysex[21] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) thresShort.getModel()).getIntValue());
        sysex[22] = tempByte[0];
        sysex[23] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) thresLong.getModel()).getIntValue());
        sysex[24] = tempByte[0];
        sysex[25] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) cymbalInput.getModel()).getIntValue());
        sysex[26] = tempByte[0];
        sysex[27] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) bowHO.getModel()).getIntValue());
        sysex[28] = tempByte[0];
        sysex[29] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) edgeHO.getModel()).getIntValue());
        sysex[30] = tempByte[0];
        sysex[31] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) bellHO.getModel()).getIntValue());
        sysex[32] = tempByte[0];
        sysex[33] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) bowCL.getModel()).getIntValue());
        sysex[34] = tempByte[0];
        sysex[35] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) edgeCL.getModel()).getIntValue());
        sysex[36] = tempByte[0];
        sysex[37] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) bellCL.getModel()).getIntValue());
        sysex[38] = tempByte[0];
        sysex[39] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) chickNote.getModel()).getIntValue());
        sysex[40] = tempByte[0];
        sysex[41] = tempByte[1];
        tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) splashNote.getModel()).getIntValue());
        sysex[42] = tempByte[0];
        sysex[43] = tempByte[1];
        sysex[44] = Common.SYSEX_END;
        return sysex;
    }

    public void stateChanged(ChangeEvent e) {
        if (!tempDisableStateChangedEvents) {
            //for low and high level, to avoid setting high level lower than low level or viceversa
            //this block is inside the tempDisableStateChangeEvents to allow application to have low values
            //higher than high values, if they are set that way in Megadrum
            if (e.getSource() == lowLevel) {
                if (((Integer) lowLevel.getValue()).intValue() >= ((Integer) highLevel.getValue()).intValue()) {
                    highLevel.setValue(((Integer) lowLevel.getValue()).intValue() + 1);
                }
            } else if (e.getSource() == highLevel) {
                if (((Integer) lowLevel.getValue()).intValue() >= ((Integer) highLevel.getValue()).intValue()) {
                    lowLevel.setValue(((Integer) highLevel.getValue()).intValue() - 1);
                }
            } else if (e.getSource() == closedLevel) {
                if (((Integer) openLevel.getValue()).intValue() >= ((Integer) closedLevel.getValue()).intValue()) {
                    openLevel.setValue(((Integer) closedLevel.getValue()).intValue() - 1);
                }
            } else if (e.getSource() == openLevel) {
                if (((Integer) openLevel.getValue()).intValue() >= ((Integer) closedLevel.getValue()).intValue()) {
                    closedLevel.setValue(((Integer) openLevel.getValue()).intValue() + 1);
                }
            }

            //Some parameter has been changed, if Live Editing is enabled, schedule a sending
            if (parent.getLiveEditingEnabled()) {
                parent.scheduleSending(Common.HIHAT_EVENT);
            }
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSpinner altIn;
    private javax.swing.JSpinner autoLevels;
    private javax.swing.JSpinner bellCL;
    private javax.swing.JSpinner bellHO;
    private javax.swing.JSpinner bowCL;
    private javax.swing.JSpinner bowHO;
    private javax.swing.JSpinner ccValue;
    private javax.swing.JSpinner chickDelay;
    private javax.swing.JSpinner chickNote;
    private javax.swing.JSpinner closedLevel;
    private javax.swing.JSpinner curve;
    private javax.swing.JSpinner cymbalInput;
    private javax.swing.JSpinner edgeCL;
    private javax.swing.JSpinner edgeHO;
    private javax.swing.JSpinner highLevel;
    private javax.swing.JSpinner lowLevel;
    private javax.swing.JSpinner openLevel;
    private javax.swing.JSpinner reverseLevels;
    private javax.swing.JSpinner splashNote;
    private javax.swing.JSpinner thresLong;
    private javax.swing.JSpinner thresShort;
    private javax.swing.JSpinner type;
    // End of variables declaration//GEN-END:variables
    private MegadrumConfigTool parent;
    private JSpinner parameter[];
    private boolean tempDisableStateChangedEvents = false;
}
